public class Hero {
    protected String name;
    protected int life;
    protected int damage1;
    protected int defence;


    public Hero(String name, int life, int damage1, int defence) {
        this.name = name;
        this.life = life;
        this.damage1 = damage1;
        this.defence = defence;
    }

    public void attacked(int damage) {
        if (damage > defence) {
            life -= (damage - defence);
            System.out.println(name + "受到" + damage + "点伤害！");
            System.out.println(name + "剩余生命值：" + life);
        } else {
            show();
        }
    }

    public void show() {
        System.out.println(name + "成功防御了对方的攻击！");
    }
}
